<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center wtxq_flex_0_higd"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub wtxq_fd0_0_higd'>
					<view class='flex flex-wrap align-center wtxq_fd0_0_c0_higd' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  wtxq_fd0_0_c0_c0_higd'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='wtxq_fd0_0_c1_c0_higd' v-if=" type=='1'">{{$t('巡更详情')}}</text><text
							class='wtxq_fd0_0_c1_c0_higd' v-if=" type=='2'">{{$t('风险评估整改任务')}}</text><text
							class='wtxq_fd0_0_c1_c0_higd' v-if=" type=='3'">{{$t('问题审核')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end xgxq_fd0_0_c0_higd'>
						<!-- #ifndef MP-WEIXIN -->
						<text  @tap.stop="saoFunc" v-if=" type=='1'" class='fu-iconfont2  xgxq_fd0_0_c2_c0_higd'>&#xe6e4;</text>
						<!-- #endif -->
						
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction align-stretch benben-flex-layout">
				<view class='flex flex-direction align-stretch wtxq_fd1_0_higd'>
					<view class='flex flex-direction align-stretch wtxq_fd1_0_c0_higd'>
						<view class='flex flex-wrap align-center wtxq_fd1_0_c0_c0_higd'>
							<text>{{$t('巡更路线：')}}</text>
							<text>{{info.info.rcxglx_xglxmc}}</text>
						</view>
						<view class='flex flex-wrap align-center wtxq_fd1_0_c0_c1_higd' v-if=" type=='2'">
							<image class='wtxq_fd1_0_c0_c1_c0_higd' mode="aspectFit" :src='STATIC_URL+"102.png"'
								v-if=" info.info.zg_status=='1'"></image>
							<image class='wtxq_fd1_0_c0_c1_c0_higd' mode="aspectFit" :src='STATIC_URL+"103.png"'
								v-if=" info.info.zg_status=='2'"></image>
							<image class='wtxq_fd1_0_c0_c1_c0_higd' mode="aspectFit" :src='STATIC_URL+"104.png"'
								v-if=" info.info.zg_status=='3'"></image>
							<text class='wtxq_fd1_0_c0_c1_c1_higd'
								v-if=" info.info.zg_status=='1'">{{$t('待整改')}}</text><text
								class='wtxq_fd1_0_c0_c1_c1_1_higd'
								v-if=" info.info.zg_status=='2'">{{$t('整改中')}}</text><text
								class='wtxq_fd1_0_c0_c1_c1_1_higd' v-if=" info.info.zg_status=='3'">{{$t('已完成')}}</text>
						</view>
						<view class='flex flex-wrap align-center wtxq_fd1_0_c0_c2_higd' v-if=" type=='1'">
							<image class='wtxq_fd1_0_c0_c1_c0_higd' mode="aspectFit" :src='STATIC_URL+"102.png"'
								v-if=" info.info.status=='1'"></image>
							<image class='wtxq_fd1_0_c0_c1_c0_higd' mode="aspectFit" :src='STATIC_URL+"103.png"'
								v-if=" info.info.status=='2'"></image>
							<image class='wtxq_fd1_0_c0_c1_c0_higd' mode="aspectFit" :src='STATIC_URL+"104.png"'
								v-if=" info.info.status=='3'"></image>
							<text class='wtxq_fd1_0_c0_c1_c1_higd'
								v-if=" info.info.status=='1'">{{$t('未开始')}}</text><text
								class='wtxq_fd1_0_c0_c1_c1_1_higd' v-if=" info.info.status=='2'">{{$t('巡更中')}}</text>
								<text
								class='wtxq_fd1_0_c0_c1_c1_1_higd' v-if=" info.info.status=='3'">{{$t('已完成')}}</text>
						</view>
						<view class='flex flex-wrap align-center wtxq_fd1_0_c0_c3_higd'>
							<text class='wtxq_fd1_0_c0_c3_c0_higd'>{{$t('巡更点数量')}}</text>
							<text class='wtxq_fd1_0_c0_c3_c1_higd'>{{info.info.num}}</text>
							<text class='wtxq_fd1_0_c0_c3_c1_higd'>/</text>
							<text class='wtxq_fd1_0_c0_c3_c1_higd'>{{info.info.total_num}}</text>
						</view>
					</view>
				</view>
				<view class='flex flex-direction align-stretch wtxq_fd1_1_higd'>
					<view class='flex flex-wrap align-center wtxq_fd1_1_c0_higd'>
						<text class='wtxq_fd1_1_c0_c0_higd' v-if=" type=='1'">{{$t('巡更点')}}</text><text
							class='wtxq_fd1_1_c0_c0_higd' v-if=" type=='2'">{{$t('专项检查项')}}</text><text
							class='wtxq_fd1_1_c0_c0_higd' v-if=" type=='3'">{{$t('隐患排查项')}}</text>
							<!-- #ifdef MP-WEIXIN -->
							<text  @tap.stop="saoFunc" v-if=" type=='1'" style="margin: 0 32rpx 0 auto;" class='fu-iconfont2  xgxq_fd0_0_c2_c0_higd'>&#xe6e4;</text>
							<!-- #endif -->
					</view>
					<view class='flex flex-direction align-stretch'>
						<template v-for='(item,key0) in info.list'>
							<view class='flex flex-direction align-stretch wtxq_fd1_1_c1_c0_higd'
								@tap.stop="jumpFunc(item)" :key='key0'>
								<view class='flex flex-wrap align-center justify-between wtxq_fd1_0_c0_c3_higd'>
									<view class='flex flex-wrap align-center'>
										<text>{{item.xgmc}}</text>
									</view>
									<view class='flex flex-wrap align-center'>
										<view class='flex flex-wrap align-center wtxq_fd1_1_c1_c0_c0_c1_c0_higd'
											v-if=" type=='1'">
											<text class='wtxq_fd1_1_c1_c0_c0_c1_c0_c0_higd'
												v-if=" item.status=='1'">{{$t('未巡更')}}</text><text
												class='wtxq_fd1_1_c1_c0_c0_c1_c0_c0_1_higd'
												v-if=" item.status=='2'">{{$t('已巡更')}}</text>
										</view>
										<view class='flex flex-wrap align-center wtxq_fd1_1_c1_c0_c0_c1_c0_higd'
											v-if=" type=='2'">
											<text class='wtxq_fd1_1_c1_c0_c0_c1_c1_c0_higd'
												v-if=" item.wtzt=='1'">{{$t('待整改')}}</text><text
												class='wtxq_fd1_1_c1_c0_c0_c1_c1_c0_1_higd'
												v-if=" item.wtzt=='2'">{{$t('已完成')}}</text>
										</view>
										<!--     <view   class='flex flex-wrap align-center wtxq_fd1_1_c1_c0_c0_c1_c0_higd'    v-if= " type=='3'"  >
        <text class='wtxq_fd1_1_c1_c0_c0_c1_c2_c0_higd'    v-if= " item.wtzt=='1'"  >{{$t('待审核')}}</text><text class='wtxq_fd1_1_c1_c0_c0_c1_c2_c0_1_higd'    v-if= " item.wtzt=='2'"  >{{$t('已完成')}}</text>
</view>
 --><text class='fu-iconfont2'>&#xe7f2;</text>
									</view>
								</view>
								<view class='flex flex-wrap align-center wtxq_fd1_1_c1_c0_c1_higd'>
									<text class='wtxq_fd1_1_c1_c0_c1_c0_higd'>{{item.address}}</text>
								</view>
							</view>
						</template>

					</view>
				</view>
			</view>

			<!---flex布局flex布局结束-->
			<!--    <view class="flex flex-wrap align-center justify-center benben-position-layout flex wtxq_flex_2_higd"    >
        <button class='wtxq_fd2_0_higd'   >{{$t('完成巡更')}}</button>

        </view> -->
			<view :style="{height: '88rpx'}"></view>


		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				/** zg_status【问题状态】 **/
				"info": {
					/** zg_status【问题状态】 **/
					"info": {
						"aid": "",
						"rcxglx_xglxmc": "",
						"status": "",
						"rcxglx_xgsc": "",
						"xgfs": "",
						"status_name": "",
						"zg_status": "",
						"total_num": "",
						"num": ""
					},
					"list": []
				},
				"aid": "",
				"status": "",
				"title": "",
				"address": "",
				"qy": "",
				/** xgdid【巡更点id】 **/ "xgdid": "",
				/** xgjgid【巡更结果id】 **/ "xgjgid": "",
				"id": "1",
				"type": ""
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			let {
				id,
				type
			} = options
			if (id !== undefined) this.id = id
			if (type !== undefined) this.type = type
			this.getinfoFunc()
			this.diyPageListen()
		},
		onUnload() {
			this.diyOffPageListen()
		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//查询日常巡更详情
			async getyo7384f264a386Func() {
				//请求方法
				//数据验证

				let datainfo = await this.$api.get(global.apiUrls.post67384f264a386, {
					rcxglx_id: this.id
				});

				if (datainfo.data.code != 1) {
					this.$message.info(datainfo.data.msg);
					return
				}
				let infoinfo = datainfo.data;
				this.info = infoinfo.data

			},
			//跳转页面
			jumpFunc(item) {
				this.status = this.type == 1 ? item.status : item.wtzt
				//1未开始 2已完成  	
				//1待整改2已完成
				this.qy = item.xgmc
				this.address = item.address
				this.aid = item.aid
				this.xgdid = item.rcxgd_id
				this.title = this.info.info.rcxglx_xglxmc
				if (this.type == 1 && item.status == 2 && item.xgjg == 2) {
					//已巡更 异常
					this.aid = item.xgjg_id
				}
				if (this.type == 1 && item.status == 2 && item.xgjg == 1) {
					//已巡更 正常
					return
				}
				this.xgjg_id = item.xgjg_id
				console.log('aid' + this.aid)
				console.log('title' + this.title)
				console.log('qy' + this.qy)
				console.log('status' + this.status)
				console.log('address' + this.address)


				if (this.type == '1') {
					if (this.status == '1') {
						this.$message.info('请扫码巡更')
						return
						this.$urouter.navigateTo(
							`/pagercxg/rcksxg/rcksxg?id=${this.aid}&address=${this.address}&qy=${this.qy}&title=${this.title}`
							);
					} else {
						this.$urouter.navigateTo(`/pagercxg/rcxgover/rcxgover?id=${this.aid}&title=${this.title}`);
					}
				} else {
					if (this.status == '1') {
						this.$urouter.navigateTo(
							`/pagercxg/rcwtzg/rcwtzg?id=${this.xgdid}&title=${this.title}&ids=${this.aid}`);
					} else {
						this.aid = item.aid
						this.$urouter.navigateTo(
							`/pagercxg/rczgover/rczgover?id=${this.aid}&title=${this.title}&ids=${this.aid}`);
					}
				}
			},
			async saoFunc() {
				// if (!this.info.info.sjkssj) {
				// 	this.$message.info('请先点击开始巡更')
				// 	return
				// }
				let _this = this
				console.log('扫')
				//  #ifdef H5
				_this.getxg('3781794')
				return
				// #endif 
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						console.log(res)
					},
					complete: function(res) {
						uni.showLoading({
							'title': '识别中...'
						});
						setTimeout(function() {
							uni.hideLoading();
						}, 1000);
						if (res.result) {
							console.log(res.result)
							console.log(typeof(res.result))
							console.log(JSON.parse(res.result).qrCode)
							let code = JSON.parse(res.result).qrCode
							_this.getxg(code)
			
						} else {
							setTimeout(function() {
								uni.hideLoading();
							}, 800);
						}
					},
					fail: function(res) {
						setTimeout(function() {
							uni.hideLoading();
						}, 800);
					}
				})
			},
			
			// 获取巡更信息
			async getxg(code){
					let datalist = await this.$api.get(global.apiUrls.post685261f007bdc, {
						qr_code:code
					});
					console.log(datalist)
					if (datalist.data.code != 1) {
						this.$message.info(datalist.data.msg);
						return
					}
					let infolist = datalist.data.data;  
					console.log(infolist)
					if(infolist){
						if(infolist.is_xungeng==2){
							this.$message.info('此巡更点您已巡更完毕')
							return
						}
						this.$urouter.navigateTo(
						`/pagercxg/rcksxg/rcksxg?id=${infolist.xgxq_id}&address=${infolist.xgmc}&qy=${infolist.address}&title=${infolist.lx_name}`);
					}else{
						uni.showModal({
							title:'您包含的巡更任务不包含此巡更点',
							duration:3000,
						})
						
					}
							
			},
			//跳转巡更
			xg() {
				this.$urouter.navigateTo(
					`/pagercxg/rcksxg/rcksxg?id=${this.aid}&address=${this.address}&qy=${this.qy}&title=${this.title}`
					);
			},
			
			//获取数据
			getinfoFunc() {
				console.log(this.type)
				console.log(6666666)
				if (this.type == '1') {
					this.getyo7384f264a386Func()
				} else {
					this.getxm848e5585b408Func()
				}
			},
			//查询日常巡更-问题整改
			async getxm848e5585b408Func() {
				//请求方法
				//数据验证

				let datainfo = await this.$api.get(global.apiUrls.post6848e5585b408, {
					rcxglx_id: this.id
				});

				if (datainfo.data.code != 1) {
					this.$message.info(datainfo.data.msg);
					return
				}
				let infoinfo = datainfo.data;
				this.info = infoinfo.data

			},
			//页面监听
			diyPageListen() {
				uni.$on('tjrcxg', (data) => {
					this.getyo7384f264a386Func()
				});
				uni.$on('tjrczg', (data) => {
					this.getinfoFunc()
				});
			},
			//注销页面监听
			diyOffPageListen() {
				uni.$off('tjrcxg');
				uni.$off('tjrczg');
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;

		.wtxq_flex_2_higd {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			z-index: 10;
			bottom: calc(88rpx + var(--window-bottom));

			.wtxq_fd2_0_higd {
				border-radius: 33rpx 33rpx 33rpx 33rpx;
				width: 686rpx;
				line-height: 88rpx;
				font-size: 32rpx;
				background: #D32A29;
				color: #fff;
				height: 88rpx;
			}
		}

		.wtxq_fd1_0_higd {
			width: 100%;
			padding: 16rpx 32rpx 16rpx 32rpx;

			.wtxq_fd1_0_c0_higd {
				background: rgba(255, 255, 255, 1);
				background-size: 100% auto;
				border-radius: 16rpx;
				padding: 0rpx 24rpx 0rpx 24rpx;
				color: rgba(153, 153, 153, 1);
				font-size: 28rpx;
				position: relative;

				.wtxq_fd1_0_c0_c0_higd {
					font-size: 32rpx;
					font-weight: 500;
					color: #333;
					margin: 24rpx 0rpx 24rpx 0rpx;
				}

				.wtxq_fd1_0_c0_c1_higd {
					position: absolute;
					z-index: 2;
					width: 116rpx;
					height: 48rpx;
					right: 0rpx;
					font-size: 24rpx;
					color: var(--benbenFontColor3);
					text-align: center;
				}

				.wtxq_fd1_0_c0_c2_higd {
					position: absolute;
					z-index: 2;
					width: 116rpx;
					height: 48rpx;
					right: 0rpx;
					color: var(--benbenFontColor3);
					font-size: 24rpx;
					text-align: center;
				}
			}
		}

		.wtxq_fd1_0_c0_c1_c0_higd {
			width: 116rpx;
			height: 48rpx;
			border-radius: 0rpx;
			position: absolute;
			right: 0rpx;
		}

		.wtxq_fd1_0_c0_c1_c1_higd {
			position: absolute;
			right: 0rpx;
			z-index: 3;
			width: 116rpx;
			height: 48rpx;
			font-size: 24rpx;
			color: var(--benbenFontColor3);
			text-align: center;
		}

		.wtxq_fd1_0_c0_c1_c1_1_higd {
			position: absolute;
			right: 0rpx;
			z-index: 3;
			width: 116rpx;
			height: 48rpx;
		}

		.wtxq_fd1_0_c0_c3_higd {
			line-height: 88rpx;

			.wtxq_fd1_0_c0_c3_c0_higd {
				width: 170rpx;
			}
		}

		.wtxq_fd1_0_c0_c3_c1_higd {
			color: #333;
		}

		.wtxq_fd1_1_higd {
			background: rgba(255, 255, 255, 1);
			background-size: 100% auto;
			margin: 0rpx 32rpx 0rpx 32rpx;

			.wtxq_fd1_1_c0_higd {
				line-height: 88rpx;
				padding: 0rpx 0rpx 0rpx 24rpx;
			}

			.wtxq_fd1_1_c1_c0_higd {
				padding: 0rpx 24rpx 0rpx 24rpx;
				margin: 0rpx 0rpx 32rpx 0rpx;
				background: rgba(255, 255, 255, 1);
				background-size: 100% auto;
				border-radius: 16rpx;
				border-bottom: 1px solid #eee;

				.wtxq_fd1_1_c1_c0_c1_higd {
					line-height: 66rpx;

					.wtxq_fd1_1_c1_c0_c1_c0_higd {
						color: rgba(153, 153, 153, 1);
						font-size: 24rpx;
					}
				}
			}
		}

		.wtxq_fd1_1_c0_c0_higd {
			color: #333;
			font-size: 32rpx;
			font-weight: 500;
		}

		.wtxq_fd1_1_c1_c0_c0_c1_c0_higd {
			height: 40rpx;

			.wtxq_fd1_1_c1_c0_c0_c1_c0_c0_higd {
				height: 40rpx;
				line-height: 40rpx;
				color: var(--benbenFontColor6);
				width: 96rpx;
				text-align: center;
				font-size: 24rpx;
				border: 1px solid rgba(255, 140, 0, 1);
				border-radius: 8rpx;
			}

			.wtxq_fd1_1_c1_c0_c0_c1_c0_c0_1_higd {
				color: rgba(255, 255, 255, 1);
				height: 40rpx;
				line-height: 40rpx;
				background: rgba(68, 141, 247, 1);
				background-size: 100% auto;
				width: 96rpx;
				font-size: 24rpx;
				text-align: center;
				border-radius: 8rpx;
			}
		}

		.wtxq_fd1_1_c1_c0_c0_c1_c1_c0_higd {
			line-height: 40rpx;
			height: 40rpx;
			font-size: 24rpx;
			color: var(--benbenFontColor6);
			text-align: center;
			width: 96rpx;
			border: 1px solid var(--benbenbdColor3);
			border-radius: 8rpx;
		}

		.wtxq_fd1_1_c1_c0_c0_c1_c1_c0_1_higd {
			color: rgba(235, 149, 75, 1);
			border: 1px solid rgba(235, 149, 75, 1);
			height: 40rpx;
			line-height: 40rpx;
			width: 96rpx;
			text-align: center;
			font-size: 24rpx;
			border-radius: 8rpx;
		}

		.wtxq_fd1_1_c1_c0_c0_c1_c2_c0_higd {
			line-height: 40rpx;
			height: 40rpx;
			color: rgba(235, 149, 75, 1);
			font-size: 24rpx;
			text-align: center;
			width: 96rpx;
			border: 1px solid var(--benbenbdColor3);
			border-radius: 8rpx;
		}

		.wtxq_fd1_1_c1_c0_c0_c1_c2_c0_1_higd {
			color: var(--benbenFontColor3);
			height: 40rpx;
			line-height: 40rpx;
			background: rgba(68, 141, 247, 1);
			background-size: 100% auto;
			width: 96rpx;
			font-size: 24rpx;
			text-align: center;
			border-radius: 8rpx;
		}

		.wtxq_flex_0_higd {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			z-index: 10;
			top: 0rpx;
			background: #fff;
			background-size: 100% auto !important;

			.wtxq_fd0_0_higd {
				padding: 0rpx 32rpx 0rpx 32rpx;
			}
		}

		.wtxq_fd0_0_c0_higd {
			width: 120rpx;

			.wtxq_fd0_0_c0_c0_higd {
				font-size: 36rpx;
				color: #333;
			}
		}

		.wtxq_fd0_0_c1_c0_higd {
			font-size: 36rpx;
			font-weight: 700;
			color: #333333;
			line-height: 50rpx;
		}
	}
</style>
